package com.it.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.it.domain.SalesOrder;
import com.it.service.SalesOrderService;

import com.it.mapper.SalesOrderMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SalesOrderServiceImpl extends ServiceImpl<SalesOrderMapper, SalesOrder> implements SalesOrderService {
    @Autowired
    private SalesOrderMapper salesOrderMapper;

    @Override
    public List<SalesOrder> getAllSalesOrders() {
        return salesOrderMapper.selectAllWithCustomer();
    }

    @Override
    public SalesOrder getSalesOrderById(Integer id) {
        return salesOrderMapper.selectByIdWithCustomer(id);
    }

    @Override
    public boolean createSalesOrder(SalesOrder salesOrder) {
        return salesOrderMapper.insert(salesOrder) > 0;
    }

    @Override
    public boolean updateSalesOrder(Integer id, SalesOrder salesOrder) {
        return salesOrderMapper.update(salesOrder) > 0;
    }

    @Override
    public boolean deleteSalesOrder(Integer id) {
        return salesOrderMapper.delete(id) > 0;
    }
}
